﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="author" content="Aowork">
    <meta name="description" content="">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, maximum-scale=1.0">
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no">

    <title></title>

    <link href="../css/mobile.css" rel="stylesheet" />

    <script src="../js/city.min.js"></script>

    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>

    <script src="../js/zepto.min.js"></script>
    <script src="../js/zepto.swipe.js"></script>

    <script src="../js/plupload-2.1.9/js/plupload.full.min.js"></script>
    <script src="../js/qiniu/qiniu.js"></script>

    <script src="../js/common.js"></script>
    <script src="../js/config.js"></script>
    <script src="../js/uiExtend.js"></script>
    <script src="../js/wx_config.js"></script>

    <script type="text/javascript">
        jc.fnInit.push(function () {
            jc.ui.header.trigger("updateTitle", "&nbsp;");
        });
    </script>


    <script type="text/javascript">
        jc.fnInit.push(function () {

            jc.ui.header.trigger("getUser", function (user) {
                $.getJSON(window.path.cartCount, { accessToken: user.accessToken, userId: user.uid }, function (result) {

                    if (result.success) {

                        var iconListData = [
                            {
                                imgUrl: "../images/icon/icon_3.png",
                                title: "购物车",
                                href: window.ctx + "cartList/cartList.html",
                                count: result.data.count,
                            },
                            {
                                imgUrl: "../images/icon/icon_4.png",
                                title: "我的订单",
                                href: window.ctx + "home/orderList.html",
                                count: 0,
                            },
                            {
                                imgUrl: "../images/icon/icon_5.png",
                                title: "我的课程",
                                href: window.ctx + "home/courseList.html",
                                count: 0,
                            },

                        ];
                        jc.ui.iconList.trigger("setup", iconListData);

                    }
                    else {
                        window.errorRouter(result.desc);
                    }

                });

            });

        });


    </script>

    <script type="text/javascript">
        jc.fnInit.push(function () {
            jc.ui.header.trigger("getUser", function (user) {

                $.getJSON(window.path.profile, { accessToken: user.accessToken, userId: user.uid }, function (result) {
                    if (!result.success) {
                        window.errorRouter(result.desc);
                    }

                    var data = result.data;

                    /* 用户设置的值 */
                    var location = data.location ? data.location.split(" ") : [];

                    
                    /* 年级 */
                    var formListGradeNameList = [];

                    $.ajax({
                        url: window.path.gradeAndSubject,
                        data: {},
                        async: false,
                        dataType: "json",
                        success: function (result) {
                            var data = result.data;
                            for (var i = 0, l = data.gradeList.length; i < l; i++) {
                                var cur = data.gradeList[i];

                                var object = {};

                                object.title = cur.name;
                                object.value = cur.name;

                                formListGradeNameList.push(object);
                            }
                        }

                    });

                    if (!data.gradeName) formListGradeNameList.unshift({ title: "请选择", value: "" });

                    /* 性别 */
                    var formListSexList = [
                        { title: "男", value: "1" },
                        { title: "女", value: "2" }
                    ]
                    if (!data.sex) formListSexList.unshift({ title: "请选择", value: "" });

                    /* 省 */
                    var formListProvinceList = [];

                    jc.ui.formList.trigger("getProvince", function (provinceArray) {
                        formListProvinceList = provinceArray;
                    });

                    if (!location[0]) formListProvinceList.unshift({ title: "请选择", value: "" });


                    /* 市 */
                    var formListCityList = [];

                    jc.ui.formList.trigger("getCity", location[0], function (cityArray) {
                        formListCityList = cityArray;
                    });

                    var sex = "";

                    if (data.sex == "1") {
                        sex = "男";
                    }
                    else if (data.sex == "2") {
                        sex = "女";
                    }
                    else {
                        sex = "请选择";
                    }

                    var readyData = [
                         {
                             id: "realName",
                             title: "姓名",
                             value: data.realName,
                             href: "homeSetRealName.html"
                         },
                         {
                             id: "gradeName",
                             title: "年级",
                             select: formListGradeNameList,
                             value: data.gradeName || "请选择"

                         },
                         {
                             id: "sex",
                             title: "性别",
                             select: formListSexList,
                             value: sex

                         },
                         {
                             id: "location1",
                             title: "省",
                             select: formListProvinceList,
                             value: location[0] || "请选择"

                         },
                         {
                             id: "location2",
                             title: "市",
                             select: formListCityList,
                             value: location[1] || "请选择"

                         },
                         {
                             title: "家长",
                             value: (data.parentName && data.parentPhoneNo ? data.parentName + " " + data.parentPhoneNo : "未设置"),
                             href: "homeSetParent.html"
                         }

                    ];

                    jc.ui.formList.trigger("ready", readyData);
                    jc.ui.userDetails.trigger("setup", result.data);
                });

                window.formListChange = function (data) {
                    data.accessToken = user.accessToken;
                    data.uid = user.uid;
                    if (data.location1 && data.location2) {
                        data.location = data.location1 + " " + data.location2;
                    }
                    $.getJSON(window.path.profileUpdate, data, function (result) {
                        if (result.success) {

                        }
                        else {
                            window.errorRouter(result.desc);
                        }
                    });
                }

            });



        });




    </script>



</head>
<body>
    <div style="display:none;" data-ui="header" class="J_header">
        <div class="h_inner"></div>
    </div>

    <div data-ui="userDetails" class="J_userDetails">

    </div>

    <div class="bgfff bt1 bb1">
        <div data-ui="iconList" class="J_iconList">
            <div class="i_list clearfix">

            </div>
        </div>
    </div>

    <div class="mt10 bgfff bt1">

        <div data-ui="formList" class="J_formList">
            <div class="f_list">

            </div>
        </div>

    </div>


    <div class="p20 tc">
        <a class="alink default" href="javascript:jc.ui.header.trigger('logout');">退出登录</a>
    </div>

</body>
</html>
